<template>
	<view>
		<view class="yi_box">
				<view class="wen_tit">问题类型</view>
				<view><picker v-if="array1.length>0" @change="bindPickerChange" :value="index" :range="array1" range-key="title">
				<view class="uni-input"><span style="margin-right: 10px;">{{array1[index].title}}</span><u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
			</picker></view>
		</view>
		<view class="shuru">
			<span class="title">描述和说明</span>
            <view style="margin-top: 30rpx;">
                <u-input type="textarea" :showWordLimit="true" v-model="info"  class="intpt"  :maxlength="200" height="260"  placeholder="请输入内容"></u-input>
            </view>
			
		</view>
		<button class="submitBtn" @click="submit()">提交</button>
	</view>
</template>

<script>
	import {submitAdvice,getAdvType} from '@/api/merchat.js'
	export default {
		data() {
			return {
			info:'',
			index:0,
			array1:[],
			type:""
			}
		},
		onLoad() {
				this.getData()
		},
		onReachBottom:function(){
				this.page++
				if(this.page>this.lastPage){
					return
				}
				this.getData()
		},
		methods:{
			getData(){
				getAdvType().then(res=>{
						for(var i in  res.data){
								let data = {
									id:i,
									title:res.data[i]
								}
								this.array1.push(data)
						}
						this.type = this.array1[0].id
				})
				
			},
				
			bindPickerChange(e){
				this.index = e.detail.value
				this.type = this.array1[this.index].id
			},
			submit(){
					
				if(!this.info){
					uni.showToast({
						title:'请输入反馈意见内容！',
						icon:'none'
					})
					return
				}
				uni.showLoading({
					title:'提交中'
				})
				submitAdvice({type:this.type,info:this.info}).then(res=>{
					uni.hideLoading()
					uni.showToast({
						title:'提交成功！',
						icon:'success'
					})
					setTimeout(()=>{
						uni.navigateBack({})
					},1500)
				})
			}
		}
	}
			
</script>

<style lang="scss" scoped>
	.yi_box{
		padding: 30rpx;
		display: flex;
	}
	.wen_tit{
		font-size: 28rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 800;
		color: #222222;
		margin-right: 12px;
		margin-bottom: 13px;
	}
	.cehgn{
		font-size: 28rpx;
		margin-right: 5px;
	}
	.shuru{
		width: 750rpx;
		height: 360rpx;
		background: #FFFFFF;
		padding: 30rpx;
		margin: 0 auto;
		.title{
			font-weight: 800;
		}
	}
	.submitBtn{
		    background: linear-gradient(315deg, #FF7E4A 0%, #FC5351 100%);
		    color: #fff;
		    width: 600rpx;
			margin-top: 20rpx;
	}
</style>
